/* Project: Jonkotrade | Author: Jalil Benayachi / Thejals.com - based on JS tutorials  */
/*--------------------------------------------------------------------------------------*/
(function($) {

"use strict";

$(document).ready(function() {




	// Input placeholder fallback
	$('input, textarea').placeholder();


	$('.flexslider').flexslider({
		selector: ".slides > .review",
		directionNav: false,
		slideshow: true,
		slideshowSpeed: 5000,
		animationLoop: true,
		animation: "slide",
		direction: "horizontal"
	});

	/* Header
	------------------*/
	
	$(window).scroll( function() {

		// Scale down header
		if ( $(this).scrollTop() < 500 ) {
			$('#header').removeClass('scaled-down');
		} else {
			$('#header').addClass('scaled-down');
		}

		if ( $(window).scrollTop() < 1000 ) {
			$('#back-to-top').fadeOut();
		} else {
			$('#back-to-top').fadeIn();
		}
	}); // $(window).scroll( function()


	// Mobile Menu Toggle
	$('#menu-toggle').click( function( e ) {
		e.preventDefault();
		$(this).toggleClass('open');
		$('#menu').slideToggle(400);
	});
	
	/*------------------
	End Header */
	

	/* Footer
	------------------*/
	// back to top
	$('#back-to-top').click( function( e ) {
		e.preventDefault();

		$('html, body').animate({ scrollTop: 0 }, 800);
	});


	/* Contact Form
	------------------*/
	$('#contact-form').validate({
	rules: {
		name: {
			required: true,
			minlength: 2
		},
		email: {
			required: true,
			email: true
		},
		message: {
			required: true,
			minlength: 10
		}
	},
	messages: {
		name: "* Please enter in your name.",
		email: "* Please enter a valid email address.",
		message: "* Please enter your message."
	},
	errorElement: "div",
	errorPlacement: function(error, element) {
		element.before(error);
	}
});

		$('#register-form').validate({
	rules: {
		name: {
			required: true,
			minlength: 2
		},
		email: {
			required: true,
			email: true
		},
		password: {
			required: true,
			minlength: 8
		}
		,
		phone: {
			required: true,
			minlength: 6
		},
		birth: {
			required: true
		}
		,
		address: {
			required: true,
			minlength: 10
		}
		
	},
	messages: {
		name: "* Please enter your name.",
		email: "* Please enter a valid email address.",
		password: "* Please enter a valid password (at least 8 characters)"
		phone: "* Please enter a valid phone number",
		birth: "* You must be aged at least 18 to use this website.",
		address: "* Please enter your address."
	},
	errorElement: "div",
	errorPlacement: function(error, element) {
		element.before(error);
	}
});


});
}(jQuery));